/*
ID:fuxiang2
PROG: dualpal
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <cmath>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define DWN(i, b, a) for (int i=int(b-1);i>=int(a);--i)
#define REP_1(i, n) for (int i=1;i<=int(n);++i)
#define FOR_1(i, a, b) for (int i=int(a);i<=int(b);++i)
#define DWN_1(i, b, a) for (int i=int(b);i>=int(a);--i)



using namespace std;
ofstream fout ("dualpal.out");
ifstream fin ("dualpal.in");
char NUMBER[20] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};

string convert(int n, int b)
{
	string number;
	while (n) {
		number.insert(number.begin(), NUMBER[n%b]);
		n /= b;
	}
	return number;
}

bool is_plalindrome(string s)
{

	for (string::iterator back = s.begin(), forward = s.end()-1;
		back < forward; ++back, --forward) {
			if (*back != *forward)
				return false;
	}
	return true;
}

int main()
{

	int n,s;

	fin >> n>>s;
	
	s ++;
	for(; n > 0 ; s++)
	{
		int count = 0;
		FOR_1(j,2,10){
			string str = convert(s,j);

			if(is_plalindrome( str))
				count ++;
			if(count >= 2)
				break;
		}
		if(count >= 2){
			n --;
			fout << s<<endl;
		}
	}

	return 0;
}

